package com.zlx.mall.basic.common.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotBlank;

/**
 * @author qingke
 **/
@Data
@NoArgsConstructor
public class SystemParam {

    /**
     * 登录Token
     */
    private String token;

    /**
     * App Code
     */
    //@NotBlank(message = "appCode不允许为空")
    private String appCode;

    /**
     * Channel Code
     */
    private String channel;

    /**
     * APP Version
     */
    //@NotBlank(message = "appVersion不允许为空")
    private String appVersion;

    /**
     * 网络类型 3G/4G/5G/WIFI
     */
    private String networkType;

    /**
     * 设备ID
     */
    //@NotBlank(message = "deviceId不允许为空")
    private String deviceId;

    /**
     * deviceType
     */
    //@NotBlank(message = "deviceType不允许为空")
    private String deviceType;

    /**
     * netType
     */
    private String netType;

    /**
     * wifiName
     */
    private String wifiName;

    /**
     * time
     */
    private String time;

    /**
     * clientType：h5，ios ，android）终端操作系统类型
     */
    //@NotBlank(message = "clientType不允许为空")
    private String clientType;

    /**
     * clientTypeVersion  应用版本
     */
    //@NotBlank(message = "clientTypeVersion不允许为空")
    private String clientTypeVersion;

    /**
     * source
     */
    private String source;

    /**
     * APK Version Number
     */
    private Integer apkVersionNum;
    private String imei;
    private String oaid;


    public Integer getApkVersionNum() {
        if (this.apkVersionNum == null) {
            if (StringUtils.hasText(appVersion)) {
                String[] versionStrArr = appVersion.split("\\.");
                this.apkVersionNum = Integer.parseInt(String.format("%02d", Integer.valueOf(versionStrArr[0])) +
                        String.format("%02d", Integer.valueOf(versionStrArr[1])) +
                        String.format("%02d", Integer.valueOf(versionStrArr[2])));
            } else {
                this.apkVersionNum = 0;
            }
        }
        return this.apkVersionNum;
    }
}
